﻿//        Another Demo from Andy L. & MissedMemo.com
// Borrow whatever code seems useful - just don't try to hold
// me responsible for any ill effects. My demos sometimes use
// licensed images which CANNOT legally be copied and reused.

using System;
using System.Linq;
using System.Xml.Linq;
using System.Collections.Generic;


namespace MissedMemo.MeatAndCheeseDisc.BusinessLogic
{
    public static class PriceLookerUpper
    {
        internal static double Price( PizzaType typeId, PizzaSize sizeId )
        {
            XElement priceList = XElement.Load( "PriceList.xml" );

            var query =
                from p in priceList.Elements( "pizza" )
                where (String)p.Attribute( "id" ) == typeId.ToString()
                    from s in p.Elements( "size" )
                    where (String)s.Attribute( "id" ) == sizeId.ToString()
                        select s.Element( "price" ).Value;

            double price = 0;
            Double.TryParse( query.ElementAt(0), out price );

            return price;
        }


        internal static double TaxRate()
        {
            //lookup...
            return .06;
        }
    }
}
